import { http } from '@/utils/http/axios';

//#region  增删改查
//获取所有数据
export function getAllList() {
  return http.request({
    url: '/System/SysRole/GetAllList',
    method: 'get',
  });
}
//获取分页数据
export function getPageList(params) {
  return http.request({
    url: '/System/SysRole/GetPageList',
    method: 'get',
    params
  });
}

/**
 * 新增
 * @returns 
 */
export function add(data: object) {
  return http.request({
    url: '/System/SysRole/Add',
    method: 'POST',
    data
  });
}


/**
 * 修改
 * @returns 
 */
export function update(data: object) {
  return http.request({
    url: '/System/SysRole/Update',
    method: 'POST',
    data
  });
}

/**
 * 修改启用状态
 * @returns 
 */
export function updateEnabled(data: object) {
  return http.request({
    url: '/System/SysRole/UpdateEnabled',
    method: 'POST',
    data
  });
}
/**
 * 删除
 * @returns 
 */
export function deleteById(id: string) {
  return http.request({
    url: `/System/SysRole/Delete?id=${id}`,
    method: 'POST',
  });
}
//#endregion


export function getRoleMenuByRoleId(roleId: string) {
  return http.request({
    url: '/System/SysRole/GetRoleMenuByRoleId',
    method: 'GET',
    params: { roleId }
  });
}
/**
 * 保存角色菜单
 * @returns 
 */
export function saveRoleMenu(data: object) {
  return http.request({
    url: '/System/SysRole/SaveRoleMenu',
    method: 'POST',
    data
  });
}